package com.msh.platform.elm.controller;

import com.msh.platform.bizmedia.base.vo.SessionData;
import com.msh.platform.bizmedia.base.conf.ResponseResult;
import com.msh.platform.bizmedia.base.exception.BusinessException;
import com.msh.platform.bizmedia.base.util.SessionUtil;
import com.msh.platform.elm.dao.DevTestRepository;
import com.msh.platform.elm.entity.DevTest;
import com.msh.platform.elm.service.DevTestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author zhangyangsong
 * @Description :
 * @Date: Created in 2018/11/8
 * @Copyright: ©2018 all rights reserved.
 */
@RestController
@RequestMapping(value = "/test")
@Api(tags = "测试用")
@Slf4j
public class TestController extends BaseController{

    @Autowired
    private DevTestService devTestService;
    
    @Autowired
    private DevTestRepository devTestRepository;
    

    @ApiOperation(value = "测试异常")
    @PostMapping(path = "/test_exception")
    public ResponseResult<String> testEx() {
        throw new BusinessException(-1,"这是一个异常测试");
    }

    @ApiOperation(value = "获取测试")
    @PostMapping(path = "/getdevtest")

    @ApiImplicitParams({
        @ApiImplicitParam(name="name",value="名称",required=true,paramType="form"),
        @ApiImplicitParam(name="uid",value="用户id",required=true,paramType="form")
    })

    /*
    public ResponseResult<DevTestVO> getDevTest(@PathVariable Integer id) {
        DevTestVO res = devTestService.getDevTest(id);
        return ResponseResult.success(res);
    }
    */
    
    public ResponseResult<List<DevTest>> getDevTest(String name,String uid) {
    	
    //	String aa = redisUtil.get("aa").toString();
        SessionData sessionData = SessionUtil.getLocalUserInfo();
        List<DevTest> devTestList = devTestRepository.findName(name, uid);
        return ResponseResult.success(devTestList);
     //   return assemblyJson(devTestList, Constants.RESPONSE_SUCCESS, "获取数据成功!");
    }
    
}
